package com.cyzy.openfeign.factory;

import com.cyzy.openfeign.DriverOpenFeign;
import com.cyzy.openfeign.impl.DriverOpenFeignImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;


@Component
public class DriverOpenFeignFactory implements FallbackFactory<DriverOpenFeign> {

    @Autowired
    private DriverOpenFeignImpl classOpenFeignImpl;

    @Override
    public DriverOpenFeign create(Throwable cause) {
        //获取报错：出发降级/熔断的原因      ----------------->    有助于开发人员或运维人员解决问题
        cause.printStackTrace(); //将这段写入日志，同时向运维人员或开发人员发送消息
        System.out.println("错误原因"+cause.getMessage());
        return classOpenFeignImpl;
//        return new ClassOpenFeignImpl();
    }
}
